<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>《机器学习》知识点整理与展示</title>
    
    <!-- 调用static静态模板 -->
    <!--Bootstrap Stylesheet [ REQUIRED ]-->
    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link rel="shortcut icon" href="../static/images/logo.jpg">

    <!--Nifty Stylesheet [ REQUIRED ]-->
    <link href="../static/css/nifty.min.css" rel="stylesheet">

    <!--Nifty Premium Icon [ DEMONSTRATION ]-->
    <link href="../static/css/nifty-demo-icons.min.css" rel="stylesheet">

    <!--Demo [ DEMONSTRATION ]-->
    <link href="../static/css/nifty-demo-icons.min.css" rel="stylesheet">
    <link href="../static/css/nifty-demo.min.css" rel="stylesheet">
    <link href="../static/css/font-awesome.min.css" rel="stylesheet">

        
    
    <!--JAVASCRIPT-->
    <!--=================================================-->
    <!--Pace - Page Load Progress Par [OPTIONAL]-->
    <link href="../static/css/pace.min.css" rel="stylesheet">
   
    <script src="../static/js/pace.min.js"></script>
   
    <!--jQuery [ REQUIRED ]-->
    <script src="../static/js/jquery-2.2.4.min.js"></script>


    <!--BootstrapJS [ RECOMMENDED ]-->
    <script src="../static/js/bootstrap.min.js"></script>

    <!--NiftyJS [ RECOMMENDED ]-->
    <script src="../static/js/nifty.min.js"></script>
    <script src="../static/js/icons.js"></script>
    <script src="../static/js/echarts.min.js"></script>


    <!--=================================================-->
    <!--Demo script [ DEMONSTRATION ]-->
    <script src="../static/js/nifty-demo.min.js"></script>
</head>

<body>

    <div id="container" class="effect aside-float aside-bright mainnav-sm">
        
        <!--NAVBAR-->
        <!--===================================================-->
        <header id="navbar">
            <div id="navbar-container" class="boxed">

                <!--Brand logo & name-->
                <!--================================-->
                <div class="navbar-header">
                    <a class="navbar-brand">
                        <img src="../static/images/logo.jpg" alt="Nifty Logo" class="brand-icon">
                        <div class="brand-title">
                            <span class="brand-text">《机器学习》</span>
                        </div>
                    </a>
                </div>
                <!--================================-->
                <!--End brand logo & name-->

                <!--Navbar Dropdown-->
                <!--================================-->
                <div class="navbar-content clearfix">
                    <ul class="nav navbar-top-links pull-left">

                        <!--Navigation toogle button-->
                        <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
                        <li class="tgl-menu-btn">
                            <a class="mainnav-toggle" href="#">
                                <i class="demo-pli-view-list"></i>
                            </a>
                        </li>
                        
                    
                    <ul class="nav navbar-top-links pull-left">
                        <h4>《机器学习》知识点整理与展示</h4>
                    </ul>
                </div>
                <!--================================-->
                <!--End Navbar Dropdown-->
            </div>
        </header>
        <!--===================================================-->
        <!--END NAVBAR-->
          <!-- MAIN CONTENT -->
        <!--===================================================-->
        <div class="boxed">
            <div id="content-container">
                <div id="page-title">
                    <h1 class="page-header text-overflow">知识点全貌</h1>
                </div>

                <!--Page content-->
                <!--===================================================-->
                <div id="page-content">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="panel">
                                <!-- <div class="panel-heading">
                                    <h3 class="panel-title">知识图谱</h3>
                                </div> -->
                                <div class="panel-body">
                                    <div id="graphContainer" style="width: 100%; height: 600px;"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--===================================================-->
                <!--End page content-->
        <!--===================================================-->
        <!-- END MAIN CONTENT -->
        <!-- FOOTER -->
        <!--===================================================-->
        <footer id="footer">

           <p class="pad-lft">Copyright&#0169; 20221113170 刘盛东 《机器学习》知识点整理与展示  &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;All Rights Reserved </p>
        </footer>
        <!--===================================================-->
        <!-- END FOOTER -->

        <!-- SCROLL PAGE BUTTON -->
        <!--===================================================-->
        <button class="scroll-top btn">
            <i class="pci-chevron chevron-up"></i>
        </button>
        
        <!--===================================================-->
    </div>
    <!--===================================================-->
    <!-- END OF CONTAINER -->

    <!-- JAVASCRIPT -->
    <!--=================================================-->
    <script>
        $(document).ready(function() {
            // 初始化知识图谱
            initGraph();
    
            // 刷新图谱按钮点击事件
            $('#refreshGraph').click(function() {
                initGraph();
            });
        });
    
        function initGraph() {
            fetch('http://127.0.0.1:5000/get_graph')
                .then(response => response.json())
                .then(response => {
                    var nodes = response.nodes;
                    var links = response.relationships;
    
                    // 使用ECharts绘制知识图谱
                    var myChart = echarts.init(document.getElementById('graphContainer'));
    
                    var option = {
                        title: {
                            text: '知识图谱',
                            subtext: '《机器学习》知识点整理与展示',
                            top: 'top',
                            left: 'left'
                        },
                        tooltip: {},
                        animationDurationUpdate: 1500,
                        animationEasingUpdate: 'quinticInOut',
                        series: [
                            {
                                type: 'graph',
                                layout: 'force',
                                symbolSize: 50,
                                roam: true,
                                label: {
                                    normal: {
                                    show: true,
                                    textStyle: {}
                                    }
                                },
                                edgeSymbol: ['circle', 'arrow'],
                                edgeSymbolSize: [4, 10],
                                edgeLabel: {
                                    fontSize: 12,
                                    show: true
                                },
                                data: nodes.map(function(node) {
                                    return {
                                        name: node.label,
                                        value: 10,
                                        symbolSize: 50
                                    };
                                }),
                                links: links.map(function(link) {
                                    return {
                                        source: link.source,
                                        target: link.target,
                                        label: {
                                            normal:{
                                                show: true,
                                                formatter: link.label,
                                                textStyle: {}
                                            }   
                                        }
                                    };
                                }),
                                categories: nodes.map(function(node) {
                                    return node.label;
                                }),
                                force: {
                                    repulsion: 1000, // 调整节点之间的斥力
                                    edgeLength: [50, 200], // 边的长度范围
                                    gravity: 0.1, // 引力系数
                                },
                                draggable: true
                            }
                        ]
                    };
    
                    myChart.setOption(option);
                })
                .catch(error => {
                    console.error('Failed to fetch graph data:', error);
                });
        }
    </script>
            
            <nav id="mainnav-container">
                <div id="mainnav">

                    <!--Menu-->
                    <!--================================-->
                    <div id="mainnav-menu-wrap">
                        <div class="nano">
                            <div class="nano-content">

                                <ul id="mainnav-menu" class="list-group">
                                    <!--Category name-->
						            <li class="list-header"> 知识点可视化</li>
                        
                                    <!--Menu list item-->
                                    
                                    <li>
                                        <a href="查询页面.html">
                                            <i class="fa fa-search" style="width:24px"></i>
                                            <span class="menu-title">
                                                <strong>检索知识点</strong>
                                            </span>
                                            
                                        </a>                                           
                                    </li>

                                    <li>
                                        <a href="展示页面.html">
                                            <i class="fa fa-pie-chart" style="width:24px"></i>
                                            <span class="menu-title">
                                                <strong>知识点全貌</strong>
                                            </span>
                                            
                                        </a>                       
                                    </li>

                                    <li>
                                        <a href="增删改查页面.html">
                                            <i class="fa fa-pie-chart" style="width:24px"></i>
                                            <span class="menu-title">
                                                <strong>增删改知识点</strong>
                                            </span>
                                            
                                        </a>                       
                                    </li>
                                    <!--Menu list item-->

						            <li class="list-divider"></li>
						
						            <!--Category name-->
						            <li class="list-header">问答系统</li>
						
						            <!--Menu list item-->
						            <li >
						                <a href="{{ url_for('KGQA') }}">
						                    <i class="fa fa-question-circle" style="width:24px"></i>
						                    <span class="menu-title">知识点问答</span>
											
						                </a>						                
						            </li>
						        </ul>  
                            </div>
                        </div>
                    </div>
                    <!--================================-->
                    <!--End menu-->
                </div>
            </nav>
            <!--===================================================-->
            <!--END MAIN NAVIGATION-->
        </div>
        <!-- FOOTER -->
        <!--===================================================-->
        <footer id="footer">

           <p class="pad-lft">Copyright&#0169; 20221113170 刘盛东 《机器学习》知识点整理与展示  &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;All Rights Reserved </p>
        </footer>
        <!--===================================================-->
        <!-- END FOOTER -->

        <!-- SCROLL PAGE BUTTON -->
        <!--===================================================-->
        <button class="scroll-top btn">
            <i class="pci-chevron chevron-up"></i>
        </button>
        <!--===================================================-->
    </div>
    <!--===================================================-->
    <!-- END OF CONTAINER -->
</body>
</html>
